package kmi;

import java.awt.Color;
import static org.junit.Assert.assertTrue;
import robocode.control.snapshot.IRobotSnapshot;
import robocode.control.testing.RobotTestBed;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.events.TurnEndedEvent;

/**
 * Illustrates JUnit testing of Robocode robots. 
 * this tests that robot is Green
 * 
 * @author Mitchell Kupfer
 */
public class TestTheGreen extends RobotTestBed {

  boolean Green = false;
  int colorChoice = Color.GREEN.getRGB();
  /**
   * Match between GreenMachine and rambot.
   * 
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.RamFire,kmi.GreenMachine";
  }

  /**
   * This test runs for 1 rounds.
   * 
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 1;
  }

  /**
   * see if we were hit, if so did we shoot.
   * 
   * @param event Info about the current state of the battle.
   */
  @Override
  public void onTurnEnded(TurnEndedEvent event) {

    // Get the snapshot of the robot GreenMachine
    IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
    
    if (robot.getBodyColor() == colorChoice    &&
       robot.getGunColor() == colorChoice     &&
       robot.getRadarColor() == colorChoice   &&
       robot.getScanColor() == colorChoice  ) {
      Green = true;
    }
   
  }

  /**
   * After the battle, check to see that we fired a red bullet the same number of times we were hit.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    assertTrue("Is Green", Green);
   
  }

}
